package com.sx.zongzhi.activity;

import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.SparseArray;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.compress.Luban;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.entity.LocalMedia;
import com.sx.zongzhi.BaseActivity;
import com.sx.zongzhi.R;
import com.sx.zongzhi.adapter.MultiImageAdapter;
import com.sx.zongzhi.adapter.SpinnerDealAdapter;
import com.sx.zongzhi.adapter.SpinnerPubAdapter;
import com.sx.zongzhi.bean.CompanyBean;
import com.sx.zongzhi.bean.GlobalBean;
import com.sx.zongzhi.bean.MsgEvent;
import com.sx.zongzhi.bean.PhotoBean;
import com.sx.zongzhi.bean.PublicBean;
import com.sx.zongzhi.presenter.DisputeDealPest;
import com.sx.zongzhi.presenter.PublicListPest;
import com.sx.zongzhi.presenter.UploadFilePest;
import com.sx.zongzhi.utils.BaseUtil;
import com.sx.zongzhi.utils.FileUtils;
import com.sx.zongzhi.utils.Global;
import com.sx.zongzhi.utils.MyRxBus;
import com.sx.zongzhi.utils.ToastUtils;
import com.sx.zongzhi.view.IDisputeDealView;
import com.sx.zongzhi.view.IPublicBeanView;
import com.sx.zongzhi.view.UploadFileView;
import com.sx.zongzhi.widget.AudioDialog;
import com.sx.zongzhi.widget.LoadDialog;
import com.zero.smallvideorecord.MediaRecorderActivity;
import com.zero.smallvideorecord.model.MediaRecorderConfig;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 矛盾纠纷办理
 */
public class DisputeDealActivity extends BaseActivity implements View.OnClickListener
        ,AdapterView.OnItemSelectedListener,IDisputeDealView,IPublicBeanView,UploadFileView {

    @BindView(R.id.tv_right) TextView tvRight;
    @BindView(R.id.sp_HandleType) Spinner sp_HandleType;
    @BindView(R.id.ll_Time) LinearLayout ll_Time;//选择时间
    @BindView(R.id.tvTime) TextView tvTime;//标题提示
    @BindView(R.id.tv_EndTime) TextView tv_EndTime;//标题提示
    //办结布局
    @BindView(R.id.ll_DealDone) LinearLayout ll_DealDone;
    @BindView(R.id.rg_YesNo) RadioGroup rg_YesNo;//化解是否成功
    @BindView(R.id.rbt_Yes) RadioButton rbtYes;//化解是否成功
    @BindView(R.id.sp_DealWay) Spinner sp_DealWay;//化解方式
    @BindView(R.id.sp_DealState) Spinner sp_DealState;//化解情况
    @BindView(R.id.et_WorkWay) EditText et_WorkWay;//后续工作措施
    @BindView(R.id.et_DealState) EditText et_DealState;//调处情况

    @BindView(R.id.llCompany) LinearLayout llCompany;//主办单位
    @BindView(R.id.tv_Company) TextView tv_Company;
    @BindView(R.id.llReportCompany) LinearLayout llReportCompany;//抄报单位
    @BindView(R.id.tv_ReportCompany) TextView tv_ReportCompany;
    @BindView(R.id.ll_Suggest) RelativeLayout ll_Suggest;//办理意见
    @BindView(R.id.et_Suggest) EditText et_Suggest;
    @BindView(R.id.rv_imageRV) RecyclerView rvImageRV;
    private AudioDialog audioDialog;

    private MultiImageAdapter adapter;
    private List<PhotoBean> selectList = new ArrayList<>();
    private PopupWindow selectPop;
    /**事件步骤主键*/
    private String issueStepId;
    /**处理类型地址*/
    private final SparseArray<String> urlState=new SparseArray<>();
    /**
     * 事件办理类型 10:办理,30:结案,50:上报,70:交办,90:回退
     */
    private String stepType="10";
    private DisputeDealPest disputeDealPest;
    private PublicListPest publicListPest;
    /**所选文件*/
    private List<String> fileList;
    //化解方式
    private List<GlobalBean> dealWay;
    //化解情况
    private List<GlobalBean> dealState;
    /**已选主办单位*/
    private CompanyBean dictsBean;
    /**已选抄办单位*/
    private CompanyBean dictsBeanList;
    /**当前界面的名字*/
    private String currentPager="";
    private String operationList;
    private List<String> dealList=new ArrayList<>();
    @Override
    public void setUI(Bundle savedInstanceState) {
        setContentView(R.layout.activity_dispute_deal);
        setTitleName("矛盾纠纷办理");
        setTitleRight(R.string.confirm);
        currentPager=getIntent().getStringExtra(Global.ACTIVITY_FRAGMENT);
        issueStepId=getIntent().getStringExtra("IssueStepId");
        operationList=getIntent().getStringExtra("operationList");
        ButterKnife.bind(this);
        disputeDealPest=new DisputeDealPest(this);
        publicListPest=new PublicListPest(this);
        initView();
    }

    private void initView() {
        urlState.put(10,"dealIssueHandle.action");//办理
        urlState.put(30,"dealIssueClosed.action");//办结
        urlState.put(70,"dealIssueAssign.action");//交办
        urlState.put(50,"dealIssueReport.action");//上报
        urlState.put(90,"dealIssueFallback.action");//回退
        if (!BaseUtil.isEmpty(operationList)){
            String[] dealWay=operationList.split(",");
            dealList=Arrays.asList(dealWay);
            SpinnerDealAdapter adapter=new SpinnerDealAdapter(this,R.layout.item_text,dealList);
            sp_HandleType.setAdapter(adapter);
        }

        tvRight.setOnClickListener(this);
        ll_Time.setOnClickListener(this);
        llCompany.setOnClickListener(this);
        llReportCompany.setOnClickListener(this);
        sp_HandleType.setOnItemSelectedListener(this);
        rvImageRV.setLayoutManager(new LinearLayoutManager(this, LinearLayout.HORIZONTAL, false));
        adapter = new MultiImageAdapter(this, mAddPicClickListener);
        adapter.setList(selectList);
        rvImageRV.setAdapter(adapter);
        adapter.setOnItemClickListener(new MultiImageAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(final int position, View v) {
                String type = selectList.get(position).getSuffixType();
                String path = selectList.get(position).getPath();
                if(".mp4".equalsIgnoreCase(type)){
                    startActivity(new Intent(DisputeDealActivity.this, VideoPlayerActivity.class).putExtra(
                            "path",path));
                }else if(".wav".equalsIgnoreCase(type) || ".amr".equalsIgnoreCase(type)){
                    if (audioDialog!=null){
                        audioDialog.startPlay(path);
                    }
                }else if (".jpeg".equalsIgnoreCase(type)||".png".equalsIgnoreCase(type)||
                        ".jpg".equalsIgnoreCase(type)){
                    startActivity(new Intent(DisputeDealActivity.this, ImagePlayActivity.class).putExtra(
                            "path", path));
                }else {
                    ToastUtils.showToast(DisputeDealActivity.this,"不能查看文件");
                }
            }
        });

    }

    //点击的添加文件的响应
    private MultiImageAdapter.AddPicClickListener mAddPicClickListener = new MultiImageAdapter.AddPicClickListener() {
        @Override
        public void onAddPicClick() {
            int max = 3 - selectList.size();
            if (max > 0) {
                showPopupSelect();
            } else {
                ToastUtils.showToast(DisputeDealActivity.this,"最多上传三项");
            }
        }
    };

    /**
     * 显示选择文件的弹窗
     */
    private void showPopupSelect() {
        View view = LayoutInflater.from(this).inflate(R.layout.pop_select_file, null);
        if (selectPop == null) {
            selectPop = new PopupWindow(view, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true);
            selectPop.setTouchable(true);
            selectPop.setOutsideTouchable(false);
            selectPop.setBackgroundDrawable(new ColorDrawable(Color.alpha(128)));
        }
        view.findViewById(R.id.tv_Picture).setOnClickListener(this);
        view.findViewById(R.id.tv_File).setOnClickListener(this);
        view.findViewById(R.id.tv_Audio).setOnClickListener(this);
        view.findViewById(R.id.tv_Video).setOnClickListener(this);
        view.findViewById(R.id.tv_Cancel).setOnClickListener(this);
        selectPop.showAtLocation(view, Gravity.BOTTOM, 0, 0);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ll_Time:
                BaseUtil.createDataPop(this,tv_EndTime);
                break;
            case R.id.tv_right:
                submit();
                break;
            case R.id.llCompany://主办单位
                startCompany(0);
                break;
            case R.id.llReportCompany://抄办单位
                startCompany(1);
                break;
            case R.id.tv_Picture:
                int max = 3 - selectList.size();
                PictureSelector.create(this)
                        .openGallery(PictureMimeType.ofImage())
                        .selectionMode(PictureConfig.MULTIPLE)
                        .maxSelectNum(max)// 最大图片选择数量 int
                        .previewImage(true)// 是否可预览图片
                        .enableCrop(true)
                        .compress(true)
                        .compressGrade(Luban.CUSTOM_GEAR)
                        .compressMaxKB(200)//压缩最大值kb compressGrade()为Luban.CUSTOM_GEAR有效 int
                        .forResult(PictureConfig.CHOOSE_REQUEST);
                selectPop.dismiss();
                break;
            case R.id.tv_File://选文件
                Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
                intent.setType("*/*");
                intent.addCategory(Intent.CATEGORY_OPENABLE);
                try {
                    startActivityForResult( Intent.createChooser(intent, "Select a File to Upload"), 4447);
                } catch (android.content.ActivityNotFoundException ex) {
                    Toast.makeText(this, "Please install a File Manager.",  Toast.LENGTH_SHORT).show();
                }
                selectPop.dismiss();
                break;
            case R.id.tv_Audio:
                if (audioDialog==null){
                    audioDialog=new AudioDialog(DisputeDealActivity.this);
                    audioDialog.setCancelable(false);
                    audioDialog.getAudioBack(new AudioDialog.AudioCallback() {
                        @Override
                        public void getData(String filePath, int countdown) {
                            PhotoBean photoBean = new PhotoBean(filePath, ".amr");
                            selectList.add(photoBean);
                            if (adapter != null) adapter.notifyDataSetChanged();
                        }
                    });
                }
                audioDialog.show(audioDialog.AUDIO_RECODERD);
                selectPop.dismiss();
                break;
            case R.id.tv_Video:
                MediaRecorderConfig config = new MediaRecorderConfig.Buidler()
                        .smallVideoWidth(640)
                        .smallVideoHeight(480)
                        .recordTimeMax(10 * 1000)
                        .maxFrameRate(20)
                        .minFrameRate(8)
                        .captureThumbnailsTime(1)
                        .videoBitrate(580000)
                        .build();
                MediaRecorderActivity.goSmallVideoRecorder(this, DisputeAddActivity.class.getName(), config);
                selectPop.dismiss();
                break;
            case R.id.tv_Cancel:
                selectPop.dismiss();
                break;
        }

    }

    /**
     * 启动单位选择
     * @param i 判断类型
     */
    private void startCompany(int i) {
        if(i==0){//选主办
            Intent intent = new Intent();
            Bundle bundle = new Bundle();
            bundle.putString("issueStepId",issueStepId);
            if ("70".equals(stepType)){//交办
                bundle.putInt("SEPT_TYPE",0);
            }else {//上报
                bundle.putInt("SEPT_TYPE",1);
            }
            if (dictsBean==null){
                dictsBean=new CompanyBean();
                dictsBean.setType(0);
            }
            bundle.putSerializable("COMPANY",dictsBean);
            bundle.putSerializable("exceptList",dictsBeanList);
            intent.setClass(this,SelectCompanyActivity.class);
            intent.putExtras(bundle);
            startActivityForResult(intent,884);
        }
        if (i==1){//选抄办
            Intent intent2 = new Intent();
            Bundle bundle2 = new Bundle();
            bundle2.putString("issueStepId",issueStepId);
            if ("70".equals(stepType)){//交办
                bundle2.putInt("SEPT_TYPE",0);
            }else {//上报
                bundle2.putInt("SEPT_TYPE",1);
            }
            if (dictsBeanList==null){
                dictsBeanList=new CompanyBean();
                dictsBeanList.setType(1);
            }
            bundle2.putSerializable("COMPANY",dictsBeanList);
            bundle2.putSerializable("exceptList",dictsBean);
            intent2.setClass(this,SelectCompanyActivity.class);
            intent2.putExtras(bundle2);
            startActivityForResult(intent2,885);
        }
    }

    /**
     * 提交数据
     */
    private void submit() {
        if ("10".equals(stepType)||"90".equals(stepType)){
            dealIng();//办理回退
        }
        if ("30".equals(stepType)){
            dealDone();//办结
        }
        if ("50".equals(stepType)){
            report();
        }
        if ("70".equals(stepType)){
            assign();
        }
    }

    /**
     * 上报
     */
    private void report() {
        if (dictsBean==null||dictsBean.getRows()==null||dictsBean.getRows().size()<1) {
            ToastUtils.showToast(this, "请选择主办单位");
            return;
        }
        String etContent=et_Suggest.getText().toString().trim();
        if (etContent.length()<1||etContent.length()>1000){
            et_Suggest.setError("请输入办理意见");
            return;
        }
        if (selectList.size()>0){
            List<File> files = new ArrayList<>();
            for (PhotoBean localMedia : selectList) {
                files.add(new File(localMedia.getPath()));
            }
            LoadDialog.show(DisputeDealActivity.this, "正在上传文件...");
            new UploadFilePest(this).uploadFile(this, files);
        }else {
            LoadDialog.show(DisputeDealActivity.this, "正在提交...");
            submitReport();
        }

    }
    /**
     * 上报
     */
    private void submitReport() {
        String companyId=dictsBean.getRows().get(0).getValue();
        String companyIdList="";
        if (dictsBeanList!=null&&dictsBeanList.getRows()!=null){
            int count=dictsBeanList.getRows().size();
            for (int i=0;i<count;i++){
                CompanyBean.RowsBean rowsBean=dictsBeanList.getRows().get(i);
                if (i==count-1){
                    companyIdList=companyIdList + rowsBean.getValue();
                }else {
                    companyIdList=companyIdList + rowsBean.getValue()+",";
                }
            }
        }
        String etContent=et_Suggest.getText().toString().trim();
        disputeDealPest.disputeDeal(urlState.get(Integer.parseInt(stepType)),issueStepId,companyId,companyIdList,
                etContent,fileList);
    }

    /**
     * 交办
     */
    private void assign() {
        String time=tv_EndTime.getText().toString();
        if (time.isEmpty()){
            ToastUtils.showToast(this,"请选择化解时限");
            return;
        }
        if (dictsBean==null||dictsBean.getRows()==null||dictsBean.getRows().size()<1){
            ToastUtils.showToast(this,"请选择主办单位");
            return;
        }
        String etContent=et_Suggest.getText().toString().trim();
        if (etContent.length()<1||etContent.length()>1000){
            et_Suggest.setError("请输入办理意见");
            return;
        }
        if (selectList.size()>0){
            List<File> files = new ArrayList<>();
            for (PhotoBean localMedia : selectList) {
                files.add(new File(localMedia.getPath()));
            }
            LoadDialog.show(DisputeDealActivity.this, "正在上传文件...");
            new UploadFilePest(this).uploadFile(this, files);
        }else {
            LoadDialog.show(DisputeDealActivity.this, "正在提交...");
            submitAssign();
        }
    }

    /**
     * 交办
     */
    private void submitAssign() {
        String time=tv_EndTime.getText().toString();
        String companyId=dictsBean.getRows().get(0).getValue();
        String companyIdList="";
        if (dictsBeanList!=null&&dictsBeanList.getRows()!=null){
            int count=dictsBeanList.getRows().size();
            for (int i=0;i<count;i++){
                CompanyBean.RowsBean rowsBean=dictsBeanList.getRows().get(i);
                if (i==count-1){
                    companyIdList=companyIdList + rowsBean.getValue();
                }else {
                    companyIdList=companyIdList + rowsBean.getValue()+",";
                }
            }
        }
        String etContent=et_Suggest.getText().toString().trim();
        disputeDealPest.disputeDeal(urlState.get(Integer.parseInt(stepType)),issueStepId,time,companyId,
                companyIdList,etContent,fileList);
    }

    /**
     * 办结
     */
    private void dealDone() {
        String time=tv_EndTime.getText().toString();
        if (time.isEmpty()){
            ToastUtils.showToast(this,"请选择化解时限");
            return;
        }
        String workWay =et_WorkWay.getText().toString().trim();
        if (workWay.isEmpty()){
            ToastUtils.showToast(this,"请输入后续工作措施");
            return;
        }
        String tvState =et_DealState.getText().toString().trim();
        if (tvState.isEmpty()){
            ToastUtils.showToast(this,"请输入调处");
            return;
        }

        if (selectList.size()>0){
            List<File> files = new ArrayList<>();
            for (PhotoBean localMedia : selectList) {
                files.add(new File(localMedia.getPath()));
            }
            LoadDialog.show(DisputeDealActivity.this, "正在上传文件...");
            new UploadFilePest(this).uploadFile(this, files);
        }else {
            LoadDialog.show(DisputeDealActivity.this, "正在提交...");
            submitDone();
        }


    }
    /**
     * 办结
     */
    private void submitDone() {
        String time=tv_EndTime.getText().toString();
        boolean isSuccess=rbtYes.isChecked();
        String dealWay=((GlobalBean)sp_DealWay.getSelectedItem()).getId();
        String dealState=((GlobalBean)sp_DealState.getSelectedItem()).getId();
        String workWay =et_WorkWay.getText().toString().trim();
        String tvState =et_DealState.getText().toString().trim();
        disputeDealPest.disputeDeal(urlState.get(Integer.parseInt(stepType)),issueStepId,time,isSuccess,dealWay
                ,dealState,workWay,tvState,fileList);
    }

    /**
     * 办理/回退
     */
    private void dealIng() {
        String etContent=et_Suggest.getText().toString().trim();
        if (etContent.length()<1||etContent.length()>1000){
            et_Suggest.setError("请输入办理意见");
            return;
        }
        if (selectList.size()>0){
            List<File> files = new ArrayList<>();
            for (PhotoBean localMedia : selectList) {
                files.add(new File(localMedia.getPath()));
            }
            LoadDialog.show(DisputeDealActivity.this, "正在上传文件...");
            new UploadFilePest(DisputeDealActivity.this).uploadFile(this, files);
        }else {
            LoadDialog.show(DisputeDealActivity.this, "正在提交...");
            submitDealIng();
        }

    }

    /**
     * 办理/回退
     */
    private void submitDealIng() {
        String etContent=et_Suggest.getText().toString().trim();
        disputeDealPest.disputeDeal(urlState.get(Integer.parseInt(stepType)),issueStepId,etContent,fileList);
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            switch (requestCode) {
                case 884://主办单位
                    dictsBean= (CompanyBean) data.getSerializableExtra("COMPANY");
                    if (dictsBean.getRows()==null||dictsBean.getRows().size()<1){
                        break;
                    }
                    tv_Company.setText(dictsBean.getRows().get(0).getLabel());
                    break;
                case 885://抄办单位单位
                    dictsBeanList= (CompanyBean) data.getSerializableExtra("COMPANY");
                    String str="";
                    if (dictsBeanList.getRows()==null||dictsBeanList.getRows().size()<1){
                        break;
                    }
                    int count=dictsBeanList.getRows().size();
                    for (int i=0;i<count;i++){
                        CompanyBean.RowsBean rowsBean=dictsBeanList.getRows().get(i);
                        if (i==count-1){
                            str=str + rowsBean.getLabel();
                        }else {
                            str=str + rowsBean.getLabel()+",";
                        }
                    }
                    tv_ReportCompany.setText(str);
                    break;
                case PictureConfig.CHOOSE_REQUEST://选图片
                    List<LocalMedia> picUrls = PictureSelector.obtainMultipleResult(data);
                    if (!picUrls.isEmpty()) {
                        for (LocalMedia localMedia : picUrls) {
                            String path = localMedia.getCompressPath();
                            String type = path.substring(path.lastIndexOf("."));
                            selectList.add(new PhotoBean(path, type));
                        }
                        if (adapter != null) adapter.notifyDataSetChanged();
                    }
                    break;
                case MediaRecorderActivity.FOR_RESULT://拍视频
                    String videoUri = data.getStringExtra(MediaRecorderActivity.VIDEO_URI);
                    if (!TextUtils.isEmpty(videoUri)) {
                        String type = videoUri.substring(videoUri.lastIndexOf("."));
                        selectList.add(new PhotoBean(videoUri, type));
                        if (adapter != null) adapter.notifyDataSetChanged();
                    }
                    break;
                case 4447://选择文件
                    Uri selectedMediaUri = data.getData();
                    String path = FileUtils.getPath(this, selectedMediaUri);
                    if (!BaseUtil.isEmpty(path)) {
                        String type = path.substring(path.lastIndexOf("."));
                        if (".txt".equalsIgnoreCase(type)||".docx".equalsIgnoreCase(type)||".doc".equalsIgnoreCase(type)
                                ||".pdf".equalsIgnoreCase(type)||".xls".equalsIgnoreCase(type)){

                            selectList.add(new PhotoBean(path, type));
                            if (adapter != null) adapter.notifyDataSetChanged();
                        }else {
                            ToastUtils.showToast(this,"不支持当前类型文件上传");
                        }
                    }else {
                        ToastUtils.showToast(this,"文件异常请重新选择");
                    }
                    break;
            }
        }
    }



    @Override
    public void showMes(String str) {
        LoadDialog.dismiss(this);
        ToastUtils.showToast(this,str);
        MyRxBus.get().post(new MsgEvent(currentPager,1,str));
        finish();
    }

    @Override
    public void showError(String message) {
        LoadDialog.dismiss(this);
        ToastUtils.showToast(this,message);
    }

    /**
     * 获取字典类型
     * @param publicBean 获取公共字段
     */
    @Override
    public void getPublicList(PublicBean publicBean) {
        if ("化解方式".equals(publicBean.getDomainName())){
            dealWay=publicBean.getDicts();
            SpinnerPubAdapter adapter=new SpinnerPubAdapter(this,R.layout.item_text,dealWay);
            sp_DealWay.setAdapter(adapter);
        }
        if ("化解情况".equals(publicBean.getDomainName())){
            dealState=publicBean.getDicts();
            SpinnerPubAdapter adapter=new SpinnerPubAdapter(this,R.layout.item_text,dealState);
            sp_DealState.setAdapter(adapter);
        }

    }


    @Override
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
        switch (parent.getId()){
            case R.id.sp_HandleType://处理类型
                selectHandleType(dealList.get(position));
                break;
        }
    }
    @Override
    public void onNothingSelected(AdapterView<?> parent) {
    }

    /**处理类型选择*/
    private void selectHandleType(String  dealType) {
        stepType=dealType;
        if ("10".equals(dealType)||"90".equals(dealType)){//办理回退
            ll_Time.setVisibility(View.GONE);
            ll_DealDone.setVisibility(View.GONE);
            llCompany.setVisibility(View.GONE);
            llReportCompany.setVisibility(View.GONE);
            ll_Suggest.setVisibility(View.VISIBLE);
        }else if("30".equals(dealType)){//办结
            ll_Time.setVisibility(View.VISIBLE);
            tvTime.setText("化解时限");
            ll_DealDone.setVisibility(View.VISIBLE);
            llCompany.setVisibility(View.GONE);
            llReportCompany.setVisibility(View.GONE);
            ll_Suggest.setVisibility(View.GONE);
            if (dealWay==null) {
                publicListPest.getPublicList("化解方式");
            }
            if (dealState==null){
                publicListPest.getPublicList("化解情况");
            }
        }else if("50".equals(dealType)){//上报
            ll_Time.setVisibility(View.GONE);
            ll_DealDone.setVisibility(View.GONE);
            llCompany.setVisibility(View.VISIBLE);
            llReportCompany.setVisibility(View.VISIBLE);
            ll_Suggest.setVisibility(View.VISIBLE);
        }else if("70".equals(dealType)){
            ll_Time.setVisibility(View.VISIBLE);
            tvTime.setText("截止时间");
            ll_DealDone.setVisibility(View.GONE);
            llCompany.setVisibility(View.VISIBLE);
            llReportCompany.setVisibility(View.VISIBLE);
            ll_Suggest.setVisibility(View.VISIBLE);
        }
    }

    /**
     * 上传文件成功
     * @param beans
     */
    @Override
    public void uploadSuccess(List<PhotoBean> beans) {
        LoadDialog.dismiss(this);
        if(fileList==null){
            fileList=new ArrayList<>();
        }
        for (PhotoBean bean:beans){
            fileList.add(bean.getPath());
        }
        if ("10".equals(stepType)||"90".equals(stepType)){
            submitDealIng();
        }
        if ("30".equals(stepType)){
            submitDone();
        }
        if ("70".equals(stepType)){
            submitAssign();
        }
        if ("50".equals(stepType)){
            submitReport();
        }

    }
}
